<?php
ob_start();
session_start();
include '../../operations/connection.php';

if(!$_SESSION['user'])
{
	header( 'Location: login.php' );
}
else
{
	$username = $_SESSION['fullname'];
	$id_employee = $_SESSION['IDEmployee'];
}
$a= (string)(microtime(true)*1000);
$b=split('\.',$a);
$idboard= $b[0];

$title = $_REQUEST['title'];
$content = $_REQUEST['ncontent'];
$content = str_replace("'","",$content);
$valueradio = $_REQUEST['valueradio'];
$idboardedit = $_REQUEST['idboard'];

if(isset($_REQUEST['save'])){
	if(isset($_REQUEST['action'])){
		if($_REQUEST['action']=='edit'){
			$sql = "UPDATE board SET Title ='$title' , Content ='$content' ,CreatedDate=NOW(),Type='$valueradio' WHERE ID ='$idboardedit'";
			mysql_query($sql);
		}else{
			$sql = "INSERT INTO board(ID,Title,Type,Content,IDEmployee,CreatedDate,`View`,`Status`) 
				VALUES('$idboard','$title','$valueradio','$content','$id_employee',NOW(),0,1);";
			mysql_query($sql);
		}
	
	}
}

mysql_close($connection);


if(isset($_REQUEST['save'])){
	header("Location: ../../general-notices-admin.php");
}
ob_flush();

?>